filedesc
This crate exposes a single type: FileDesc
,
which acts as a thin wrapper around open file descriptors.
The wrapped file descriptor is closed when the wrapper is dropped,
unless FileDesc::into_raw_fd()
was called.
A raw file descriptor can be wrapper directly using FileDesc::from_raw()
,
or it can be duplicated and then wrapped using FileDesc::duplicate_raw_fd()
.
It is also possible to duplicate an already-wrapper file descriptor using FileDesc::duplicate()
.
If the platform supports it, all duplicated file descriptors are created with the close-on-exec
flag set atomically,
Example
use FileDesc;
let fd = unsafe ;
let duplicated = fd.duplicate?;
assert_eq!;
duplicated.set_close_on_exec?;
assert_eq!;